Progress bar with remaining time

fryes04

New Member
Joined
May 8, 2012
Messages
18
Hi everyone

I've managed to pull together a nice simple progress bar to let users know how long it will take to collate certain data. Example below:

Sub ProgressBar()

frmProgressBar.Show

End Sub

Sub Main()

Application.ScreenUpdating = False

Dim pctCnt As Integer
Dim cnt As Integer
Dim Completed As Single

pctCnt = 1
For cnt = 1 To 100
For a = 1 To 500000
Next
pctCnt = pctCnt + 1
Completed = pctCnt / 100
frmProgressBar.LabelProgress.Width = Completed * frmProgressBar.Width

'START OF CODE

Dim rCell As Range

For Each rCell In Range("A1:A400")

rCell.Select

Next rCell


'END OF CODE

DoEvents
Next
Unload frmProgressBar

Application.ScreenUpdating = True

End Sub

Does anyone know how to show elapsed time remaining....

Thanks in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
This part is placed in the user form, under the image used to show the progress:

Private Sub UserForm_Activate()
frmProgressBar.LabelProgress.Width = 0
Call Main
End Sub
 
Upvote 0
At the begining of my code I put:

Code:
StartTime = Time()


As part of the progress bar update I add:

Code:
ProgressBar.RemainingTime.Caption = Format(((StartTime_ab + ((Time() - StartTime) / Counter) * PctTotal) - Time()), "Hh:mm:ss")
 
Upvote 0
I placed the code inside the Module but the frame is only showing current time of day not time remaining
 
Upvote 0
ah ok I've got it.

frmProgressBar.RemainingTime.Caption = Format((Time() - StartTime / Completed), "hh:mm:ss")

Thank you for your quick response and your help
 
Upvote 0

Forum statistics

Threads
1,215,826
Messages
6,127,116
Members
449,359
Latest member
michael2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top